﻿<UserControl x:Class="CrtTBB"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:OMANE.Modules.CRT" 
             mc:Ignorable="d" 
             d:DesignHeight="400" d:DesignWidth="600">
	<UserControl.Resources>
        <ImageBrush x:Key="boutonbrush" ImageSource="../Ressources/Images/bouton.png"/>
        <ImageBrush x:Key="sasbrush" ImageSource="../Ressources/Images/200px-SAS_logo_horiz.svg.png" />
        <ImageBrush x:Key="excelbrush" ImageSource="../Ressources/Images/cycleexcel2.png" />
         
        <DataTemplate x:Key="InitTableButton">
			<Grid>
				<Button 
				Content="{Binding Name}"
                    Command="{Binding OpenLocationCommand}"
				 Background="{DynamicResource boutonbrush}" 
				 MinWidth="196" 
				 MinHeight="64" 
				 HorizontalContentAlignment="Right" 
				 Padding="1,15,30,1" 
				 FontSize="13.333" 
				 FontFamily="Tahoma" 
				 FontStyle="Normal" 
				 FontWeight="Bold">
					<Button.Style>
						<Style TargetType="Button">
							<Setter Property="Template">
								<Setter.Value>
									<ControlTemplate TargetType="Button">
										<Grid>
											<Rectangle Fill="{TemplateBinding  Background}" />
                                            <Ellipse Width="20" Height="20" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="11,13,0,0" StrokeThickness="2" Stroke="Black"  >
                                                <Ellipse.Fill>
                                                    <Binding Path="State">
                                                        <Binding.Converter>
                                                            <local:InitTableStateToColorConverter />
                                                        </Binding.Converter>
                                                    </Binding>
                                                </Ellipse.Fill>
                                            </Ellipse>
                                                <TextBlock Text="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}" />
										</Grid>
									</ControlTemplate>
								</Setter.Value>
							</Setter>
						</Style>
					</Button.Style>
				 </Button>
			</Grid>
		</DataTemplate>
        <DataTemplate x:Key="OutilProvButton">
        	<Grid>
				<Button 
				Content="{Binding Name}"
				 
				 MinWidth="175" 
				 MinHeight="80" 
				
				 
				 FontSize="13.333" 
				 FontFamily="Tahoma" 
				 FontStyle="Normal" 
				 FontWeight="Bold" Background="#FFE6BBFF" BorderBrush="#FFBF8DFF" BorderThickness="5,20,5,5" HorizontalAlignment="Center" VerticalAlignment="Center">
					<Button.Style>
						<Style TargetType="Button">
							<Setter Property="Template">
								<Setter.Value>
									<ControlTemplate TargetType="Button">
										<Border BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="20,20,0,0">
											<Grid>
												<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="20,-17,0,0">
													<Ellipse Height="15" Width="15" Fill="#FF00FF1B" Margin="0,0,2,0" Stroke="Black" />
													<Ellipse Height="15" Width="15" Fill="#FFFFF500" Margin="0,0,2,0" Stroke="Black" />
													<Ellipse Height="15" Width="15" Fill="Red" Margin="0,0,2,0" Stroke="Black" />
												</StackPanel>
											<TextBlock Text="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}" />
										</Grid>
										</Border>
									</ControlTemplate>
								</Setter.Value>
							</Setter>
						</Style>
					</Button.Style>
				 </Button>
			</Grid>
        </DataTemplate>
	</UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" MinHeight="75"/>
            <RowDefinition Height="5" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="5" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="5" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="5" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <GridSplitter HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="1" Grid.RowSpan="3" />
        <GridSplitter HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="3" Grid.RowSpan="3" />
        <GridSplitter HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="5" Grid.RowSpan="3" />
        <GridSplitter HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="1" Grid.ColumnSpan="7" />
 
        <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="0" Text="Initialisation et Paramétrage des tables" FontSize="14" FontFamily="Tahoma" TextWrapping="Wrap" FontWeight="Normal" FontStyle="Italic" />
        <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="2" Text="Calcul SAS et création des fichiers de provisionnement" FontSize="14" FontFamily="Tahoma" TextWrapping="Wrap" FontWeight="Normal" FontStyle="Italic" />
        <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="4" Text="Provisionnement des périmètres" FontSize="14" FontFamily="Tahoma" TextWrapping="Wrap" FontWeight="Normal" FontStyle="Italic" />
        <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="6" Text="Consolidation" FontSize="14" FontFamily="Tahoma" TextWrapping="Wrap" FontWeight="Normal" FontStyle="Italic" />


        <ListBox 
            Grid.Column="0"
            Grid.Row="2"
            ItemsSource="{Binding InitialisationTables}" 
            ItemTemplate="{DynamicResource InitTableButton}"
            HorizontalContentAlignment="Stretch"
            VerticalContentAlignment="Stretch" 
            BorderThickness="0">

            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <UniformGrid Rows="6" />
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>

            <ListBox.ItemContainerStyle>
                <Style TargetType="{x:Type ListBoxItem}">
                    <Setter Property="HorizontalContentAlignment" Value="Center"/>
                    <Setter Property="VerticalContentAlignment" Value="Center"/>
                    <Setter Property="Padding" Value="5"/>
                </Style>
            </ListBox.ItemContainerStyle>
            
            
        </ListBox>
      
      
        
        <UniformGrid Grid.Column="2" Grid.Row="2" Rows="2">
            <Button Background="WhiteSmoke"  HorizontalAlignment="Center" VerticalAlignment="Center" MinWidth="184" MinHeight="184">
                <Button.Style>
                    <Style TargetType="Button">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="Button">
                                    <Grid>
                                        <Viewbox  HorizontalAlignment="Center" VerticalAlignment="Center" Width="184" Height="184">
                                        <Path  x:Name="Path_109" Data="F1 M 297.886,319.594L 333.25,284.23L 413.377,284.23L 448.741,319.594L 448.741,369.617L 413.377,404.981L 333.25,404.981L 297.886,369.617L 297.886,319.594 Z " Stretch="Fill" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="5.1" StrokeMiterLimit="2.75" Fill="{TemplateBinding Background}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                                        </Viewbox>
										<Rectangle Fill="{DynamicResource sasbrush}"  HorizontalAlignment="Center" VerticalAlignment="Center" Width="75"  Height="61"/>
                                        <TextBlock Text="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}" />
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </Button.Style>
            </Button>
            <Button Command="{Binding GenerateOutilProvCommand}" Background="{DynamicResource excelbrush}" HorizontalAlignment="Center" VerticalAlignment="Center" MinWidth="184" MinHeight="184" >
                <Button.Style>
                    <Style TargetType="Button">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="Button">
                                    <Grid>
                                        <Rectangle Fill="{TemplateBinding  Background}" />
                                        <TextBlock Text="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}" />
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </Button.Style>
            </Button>
        </UniformGrid>


        <ListBox 
            Grid.Column="4"
            Grid.Row="2"
            DataContext="{Binding}"
            ItemsSource="{Binding OutilProvs}"           
            HorizontalContentAlignment="Stretch"
            VerticalContentAlignment="Stretch" 
            BorderThickness="0" ItemTemplate="{DynamicResource OutilProvButton}">

            <!--<ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <UniformGrid Rows="{Binding Count}" />
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>-->

            <ListBox.ItemContainerStyle>
                <Style TargetType="{x:Type ListBoxItem}">
                    <Setter Property="HorizontalContentAlignment" Value="Center"/>
                    <Setter Property="VerticalContentAlignment" Value="Center"/>
                    <Setter Property="Padding" Value="5,5,5,20"/>
                </Style>
            </ListBox.ItemContainerStyle>


        </ListBox>
    </Grid>
</UserControl>
